$(document).ready(function(){
	loadSysModels();
});


function loadSysModels(){
	$("#SysProContainer").jtable({
		title:"",
		paging:true,
		pageSize:10,
		gotoPageArea:'none',
		pageSizeChangeArea:false,
		columnSelectable: false,//禁用选择显示列功能
		actions:{
			listAction: appCtx + "secure/syspro/loadAllSysModels.html",
		},
		fields:{
			propId:{
				key:true,
				list:false
			},
			propName:{
				title:"属性名称",
				width:"15%"
			},
			propCode:{
				title:"属性编码",
				width:"15%"
			},
			propValue:{
				title:"属性值",
				width:"15%"
			},
			propDesc:{
				title:"属性描述",
				width:"28%"
			},
			operation:{
				title:"操作",
				width:"20%",
				userData:true,
				content:$("#operationSys").html(),
				param:"propId,propName",
				listClass:"operation"
			}
		}
	});
	
	querySysModel();
}

//初始化表单,然后添加系统属性
function initSys(){
	var url = appCtx + "secure/syspro/init.html";
	
	$.post(url,function(data){
		$("#methods").html("新增");
		$("#sysSaveModal .modal-body").html(data);
	});
	$("#sysSaveModal").modal();
}

//根据id值删除系统属性
function deleteSysModel(propId,propName){
	var url = appCtx + "secure/syspro/delete.html";
	if(window.confirm("确定删除["+propName+"]吗?")){
		$.post(url,{propId:propId},function(data){
			$("#SysProContainer").jtable("reload");
		});
	}
}

//根据条件查询
function querySysModel(){
	var params = $("#sysForm").serialize();
	$("#SysProContainer").jtable("load",params);
}

//根据id查询相应的系统属性,然后供修改用
function updateSys(propId){
	var url = appCtx + "secure/syspro/qryById.html";
	$.post(url,{propId:propId},function(data){
		$("#methods").html("修改");
		
		$("#sysSaveModal .modal-body").html(data);
	});
	$("#sysSaveModal").modal();
}

//保存系统属性
function saveSysModel(){
	var flag = $("#sysProForm").validationAjax();
	if(flag){
		var url = appCtx + "secure/syspro/save.html";
		var params = $("#sysProForm").serialize();
		$.post(url,params,function(result){
			var flag = result.flag;
			
			$("#SysProContainer").jtable("reload");
//			$("#sysModal").modal("hide");
			$("#sysSaveModal").modal("hide");
		});
}


}
